package com.nursinghome.admin.controller;

import com.nursinghome.admin.service.IndexService;
import com.nursinghome.bean.AttendanceVO;
import com.nursinghome.bean.Goods;
import com.nursinghome.bean.RespBean;
import com.nursinghome.bean.SysLog;
import com.nursinghome.common.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/admin/index")
public class IndexController {
    @Autowired
    private IndexService indexService;
    @Autowired
    private SysLogService sysLogService;
    @GetMapping("/tops")
    public RespBean top5Medical(){
        List<Map<String, Object>> maps = indexService.selectMedicalAndElderly();
        return RespBean.ok("",maps);
    }

    @GetMapping("/top5dish")
    public RespBean top5dish(){
        List<Goods> list = indexService.selectDishTop5();

        return RespBean.ok("",list);
    }
    @GetMapping("/userlog")
    public RespBean userLog(){
        List<SysLog> list = sysLogService.selectByUserName(null);
        return RespBean.ok("",list);
    }
    @GetMapping("/holiday")
    public RespBean holiday(){
        AttendanceVO holiday = indexService.holiday();
        return RespBean.ok("",holiday);
    }
}

